import {request} from "../request";
import {utils} from '../../common/utils'

//1.查询角色信息
export function getRolesPageInfo({roleName,roleNameCh,enabled,start,end,pageNum,pageSize}) {
    return request({
        url: '/sys/role/query',
        method: 'get',
        params: {
            roleName,
            roleNameCh,
            enabled,
            start,
            end,
            pageNum,
            pageSize
        }
    })
}

//2.修改角色
export function updateRole(role) {
    return request({
        url: '/sys/role/update',
        method: 'put',
        data: role
    })
}

//3.添加角色
export function addRole(role){
    return request({
        url: '/sys/role/add',
        method: 'post',
        data: role
    })
}

//4.删除角色
export function deleteRole(ids){
    let strUrl = utils.joinArrayReqParam(ids,'ids');
    return request({
        url: '/sys/role/delete' + strUrl,
        method: 'delete'
    })
}

//5、获取角色分配列表
export function getAssignRoleList(empId){
    return request({
        url: '/sys/role/emp-roles',
        method: 'get',
        params:{
            empId
        }
    })
}

//6、查询数据库是否已有相同名称的角色
export function hasSomeNameRole({id,roleNameCh}){
    return request({
        url: '/sys/role/has-some-RoleName',
        method: 'get',
        params:{
            id,
            roleNameCh
        }
    })
}

//7、查询数据库是否已有相同编码的角色
export function hasSomeNameCode({id,roleName}){
    return request({
        url: '/sys/role/has-some-RoleCode',
        method: 'get',
        params:{
            id,
            roleName
        }
    })
}
